package com.lt.tccdemo.service;

import com.lt.tccdemo.db109.dao.TOrderMapper;
import com.lt.tccdemo.db109.model.TOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author lucine
 * @version 1.0 2021/10/5 15:45
 */
@Service
public class OrderService {

    @Autowired
    private TOrderMapper orderMapper;

    /**
     *  订单回调接口
     * @param orderId
     * @return 0成功 1订单不存在
     */
    public int handlerOrder(int orderId){
        TOrder tOrder = orderMapper.selectByPrimaryKey(orderId);
        if(tOrder==null){
            return 1;
        }
        //已支付
        tOrder.setOrderStatus(1);
        tOrder.setUpdateTime(new Date());
        //系统更新
        tOrder.setUpdateUser(0);
        orderMapper.updateByPrimaryKey(tOrder);
        return 0;
    }


}
